package demo.bocweb.login_module.model;

import demo.bocweb.com.sdk.baseApi.AppUrl;
import demo.bocweb.com.sdk.apiHelper.RetrofitCreateHelper;
import demo.bocweb.com.sdk.apiHelper.RxHelper;
import demo.bocweb.com.sdk.base.BaseModel;
import demo.bocweb.com.sdk.base.bean.BaseBean;
import demo.bocweb.login_module.api.UserApi;
import demo.bocweb.login_module.bean.LoginBean;
import demo.bocweb.login_module.contract.RegisterContract;
import io.reactivex.Observable;
import okhttp3.RequestBody;

/**
 * Created by zhelun on 2018/1/26.
 */

public class RegisterModel extends BaseModel implements RegisterContract.IRegisterModel {
    public static RegisterModel newInstance() {
        return new RegisterModel();
    }

    @Override
    public Observable<BaseBean<LoginBean>> register(RequestBody body) {
        return RetrofitCreateHelper.createApi(UserApi.class, AppUrl.BASE_URL)
                .register(body)
                .compose(RxHelper.<BaseBean<LoginBean>>rxSchedulerHelper());
    }


    @Override
    public Observable sendSmsCode(RequestBody body) {
        return RetrofitCreateHelper.createApi(UserApi.class, AppUrl.BASE_URL)
                .sendSmsCode(body)
                .compose(RxHelper.<BaseBean>rxSchedulerHelper());
    }

    @Override
    public Observable checkSmsCode(RequestBody body) {
        return RetrofitCreateHelper.createApi(UserApi.class, AppUrl.BASE_URL)
                .checkSmsCode(body)
                .compose(RxHelper.<BaseBean>rxSchedulerHelper());
    }
}
